<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      let arr = [1, 3, 5, 7, 11];
      function handleData(arr, istrue) {
        let sum = 0;

        if (!istrue) {
          let avg = 0;
          for (let index = 0; index < arr.length; index++) {
            const element = arr[index];
            sum += element;
          }
          return (avg = sum / arr.length);
        } else {
          for (let index = 0; index < arr.length; index++) {
            const element = arr[index];
            sum += element;
          }
          return sum;
        }
      }

      console.log(handleData(arr, true));
    </script>
  </body>
</html>
